﻿package mortal.game.view.copy.ZZXYBattle
{
    import Message.Public.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import flash.events.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.common.menu.*;

    public class ZZXYBattleRankRender extends NoSkinCellRenderer
    {
        private var _txtRank:GTextFiled;
        private var _spName:GSprite;
        private var _txtName:GTextFiled;
        private var _txtScore:GTextFiled;
        private var _reards:Array;
        private var _player:SMiniPlayer;

        public function ZZXYBattleRankRender()
        {
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            var _loc_5:SReward = null;
            var _loc_6:BaseItem = null;
            super.data = param1;
            var _loc_2:* = param1 as ZZXYBattleRankData;
            this._player = _loc_2.player.player;
            var _loc_3:String = "#ffffff";
            if (_loc_2.rank == 1)
            {
                _loc_3 = "#F0B91B";
            }
            else if (_loc_2.rank == 2)
            {
                _loc_3 = "#DE00FF";
            }
            else if (_loc_2.rank == 3)
            {
                _loc_3 = "#2BACEB";
            }
            this._txtRank.htmlText = "<font color=\'" + _loc_3 + "\'>" + _loc_2.rank + "</font>";
            this._txtName.htmlText = "<u><a href=\'event:0\'><font color=\'#00ff00\'>" + _loc_2.player.player.name + "</font></a></u>";
            this._txtScore.htmlText = "<font color=\'" + _loc_3 + "\'>" + _loc_2.player.score + "</font>";
            this._txtName.configEventListener(TextEvent.LINK, this.clickLinckHandler);
            var _loc_4:int = 0;
            while (_loc_4 < _loc_2.rewards.length)
            {
                
                _loc_5 = _loc_2.rewards[_loc_4];
                _loc_6 = this.getRewardItem(_loc_4);
                _loc_6.x = -_loc_4 * 27 + 196;
                _loc_6.y = 1;
                _loc_6.itemCode = _loc_5.code;
                _loc_6.amount = _loc_5.num;
                _loc_4++;
            }
            return;
        }// end function

        private function getRewardItem(param1:int) : BaseItem
        {
            if (this._reards == null)
            {
                this._reards = [];
            }
            var _loc_2:* = this._reards[param1];
            if (_loc_2 == null)
            {
                _loc_2 = UIFactory.baseItem(0, 0, 23, 23, this);
                _loc_2.setItemStyle(22, ImagesConst.shortcutItemBg, 1, 1);
                _loc_2.isDragAble = false;
                _loc_2.isDropAble = false;
                _loc_2.isThrowAble = false;
                this._reards[param1] = _loc_2;
            }
            return _loc_2;
        }// end function

        private function clickLinckHandler(param1 = null) : void
        {
            PlayerMenuConst.Opearte(PlayerMenuConst.LookInfo, this._player);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._spName = UICompomentPool.getUICompoment(GSprite) as GSprite;
            this.addChild(this._spName);
            this._spName.mouseChildren = true;
            this._spName.mouseEnabled = true;
            this._spName.buttonMode = true;
            this._txtRank = UIFactory.gTextField("", 4, 2, 30, 20, this._spName, GlobalStyle.textFormatBai);
            this._txtName = UIFactory.gTextField("", 22, 2, 120, 20, this, GlobalStyle.textFormatBai);
            this._txtScore = UIFactory.gTextField("", 113, 2, 120, 20, this, GlobalStyle.textFormatBai);
            this.pushUIToDisposeVec(UIFactory.bg(0, 23, 207, 2, this, ImagesConst.SplitLine));
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._txtRank.dispose(param1);
            this._txtRank = null;
            this._spName.dispose(param1);
            this._spName = null;
            this._txtName.dispose(param1);
            this._txtName = null;
            this._txtScore.dispose(param1);
            this._txtScore = null;
            DisplayUtil.delNotUse(this._reards, 0);
            this._reards = null;
            return;
        }// end function

    }
}
